package com.yingsheng.bi.hks.template.processor.impl;

import com.yingsheng.bi.hks.template.events.AdviceEvent;
import com.yingsheng.bi.hks.template.events.Event;
import com.yingsheng.bi.hks.template.processor.InnerProcessor;
import com.yingsheng.bi.hks.template.utils.JacksonUtils;
import org.springframework.web.util.UriUtils;

import java.nio.charset.StandardCharsets;
import java.util.Map;

public class QiYueSuoNotifyDecodeProcessor extends InnerProcessor {
    @Override
    public void execInner(Event event) {
        if (event instanceof AdviceEvent) {
            AdviceEvent adviceEvent = (AdviceEvent) event;
            String contentEncode = adviceEvent.getString("content");
            String contentDecode = UriUtils.decode(contentEncode, StandardCharsets.UTF_8);
            Map<String, Object> contentMap = JacksonUtils.json2Map(contentDecode);
            adviceEvent.setOutput(contentMap);
        } else {
            super.execInner(event);
        }
    }
}
